If you are targeting the .NET 6+ development platform and not the .NET Framework, see Getting Started under new .NET using IDE instead.
If you are interested in QuickOPC-UA, your task will most certainly involve reading data from an OPC server. Here are a few steps that illustrate how to achieve that, using Microsoft Visual Studio, and a simple Windows Forms application in C#. The steps are quite similar if you are using other tools or a different programming language.
We will create a form that will read a float value from the OPC server when loaded, and immediately display the formatted value in the text box on the form.
Install QuickOPC. Make sure that you have selected an installation choice that includes .NET development.
Start Microsoft Visual Studio, and create new Visual C# or Visual Basic project, selecting “Windows Forms App (.NET Framework)” template. Make sure that in the lower part of the “New Configure your new project” dialog, the framework is set to “.NET Framework 4.7.2” or later.
Instantiate the EasyUAClient component in the form: Drag the EasyUAClient component from the “QuickOPC Components” tab of the Toolbox to the form’s design surface.
An icon labeled “easyUAClient1” will appear below the form.
If the needed components do not show in the Toolbox: See Troubleshooting the Visual Studio Extension.
Note: This is just shortcut way in Windows Forms to declaring and instantiating the component. In other environments, you can instantiate the component using the ‘new’ (C#) or ‘New’ (VB.NET) keyword, or any other way provided by the language or tool you are using.
Add a textbox to the form: Drag the TextBox component from the Toolbox to the form’s design surface. The text box should appear on the form, and in the Properties window, you will see that it has been given a “textBox1” name.
Add handler for the Load event of the form: Select the form by clicking on its design surface (make sure that you do not have any other control selected). Then, in the Properties window, choose the “Events” view (orange lightning icon), and double-click the line with “Load” event (it is under Behavior group). A “Form1_Load” text in bold font will appear next to the event name, and a new event handler will be created for the Load event. The text editor will open for the code, and the caret will be placed into the Form1_Load method.
Add following code to the beginning of the Form1.cs file:
using OpcLabs.EasyOpc.UA;
Write the event handler implementation. Add the following code to the body of Form1_Load method:
textBox1.Text = easyUAClient1.ReadValue("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853").ToString();
Build the project.
Run the application and observe the results. The text box on the form will be filled with a float value we have read from the OPC server, using a single code line!
If you are targeting an environment different from Windows Forms (such as console application, Web, or WPF), your steps will be similar. In place of Step 4, simply reference the OpcLabs.EasyOpcUA assembly, and create a new instance of OpcLabs.EasyOpc.UA.EasyUAClient object.
In runtime, all user interface features (such as controls, dialogs, and live binding; Windows Forms and WPF) and nonvisual components are supported both under .NET Framework and .NET 6+. However, "designing" them (this includes tasks like dragging from the Toolbox, or configuring in Properties window) in Visual Studio is only possible in .NET Framework projects. In order to achieve visual design for .NET 6+ projects, the developer can make two project files over the same set of source files, one targeting .NET Framework and one targeting .NET 6+, and use the project that targets .NET Framework for visual design tasks. |